package com.itheima.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;

/**
 * @version 1.0
 * @description 说明
 * @package com.itheima.aspect
 */
//@Aspect
@Slf4j
//@Component
public class RecordTimeAspect {

    //切入点表达式
    @Around("execution(* com.itheima.service.*.*(..))")
    public Object abc(ProceedingJoinPoint pjp) throws Throwable {
        long begin = System.currentTimeMillis();
        log.info("方法执行前: {}", begin);
        //调用目标方法 void
        Object result = pjp.proceed();
        long end = System.currentTimeMillis();
        log.info("方法执行后 耗时: {}", end-begin);
        // 返回目标方法的返回值
        return result;
    }
}
